package springboot.demo.dao;


import org.springframework.stereotype.Repository;
import springboot.demo.pojo.Department;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
//把这个类交给spring托管
@Repository
//部门dao
public class DepartmentDao {
    //造假数据
    private static Map<Integer, Department> department=null;
    //用类变量stati在类被初始化的时候就开始加载
    static {
        //用Map来模拟表
        department=new HashMap<Integer, Department>();
        department.put(101,new Department(101,"教学部"));
        department.put(102,new Department(102,"市场部"));
        department.put(103,new Department(103,"后勤部"));
        department.put(104,new Department(104,"教研部"));
        department.put(105,new Department(105,"运营部"));

    }

    public Collection<Department> getdepartment(){
        return department.values();
    }
    public Department getdepartmentById(Integer id){
        return department.get(id);
    }
}
